package com.guigu.dispatch.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.guigu.dispatch.entity.CacheLineUse;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.dispatch.mapper.CacheLineUseMapper;
import com.guigu.dispatch.service.CacheLineUseService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Queue;

/**
 * <p>
 * 缓冲路线使用表 服务实现类
 * </p>
 *
 * @author TaoLong
 * @since 2021-11-18
 */
@Service
@Transactional
public class CacheLineUseServiceImpl extends ServiceImpl<CacheLineUseMapper, CacheLineUse> implements CacheLineUseService {

    /**
     * 根据订单分类Id获取对应的线路Id
     *
     * @param orderClassifyId
     * @return
     */
    @Override
    public String getLineByOrderClassifyId(String orderClassifyId) {

        QueryWrapper<CacheLineUse> queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("order_classify_id", orderClassifyId);
        CacheLineUse cacheLineUse = baseMapper.selectOne(queryWrapper);
        if (ObjectUtils.isEmpty(cacheLineUse)) {
            return null;
        }
        return cacheLineUse.getCacheLineId();
    }
}
